<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增角色')" />
	<th:block th:include="include :: ztree-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
	<form class="form-horizontal m" id="form-role-add">


        <div class="form-group">
			<label class="col-sm-3 control-label">任务标题：</label>
			<div class="col-sm-9">
				<input type="text" name="title" class="form-control" placeholder="请输入文本">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">完成时间：</label>
			<div class="col-sm-9">
				<input type="text" name="startDate" class="form-control" style="width: 200px" value="2018-04-20">
			</div>
			<div class="col-sm-9" style="margin-left: 400px;margin-top: -33px" >
				<span>&#45;&#45;</span>
			</div>
			<div class="col-sm-9" style="margin-left: 430px;margin-top: -33px" >
				<input type="text" name="endDate" class="form-control" style="width: 200px" value="2018-04-20">
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label" >执行人员：</label>
			<div class="col-sm-9" style="width: 200px">
				<select class="form-control" name="dept" id="finddept">
					<option value="">请选择部门</option>
					<option value="人事部">市场部</option>
					<option value="软装部">测试部</option>
					<option value="硬装部">财务部</option>
				</select>
			</div>

			<div class="col-sm-9" style="margin-left: 450px;margin-top: -33px;width: 200px">

				<select class="form-control" id="user_name" name="user_name">
					<option value="">请选择执行人</option>
					<option value="张三">张三</option>
					<option value="李四">李四</option>
					<option value="王五">王五</option>
					<option value="张丽">张丽</option>
					<option value="张莉">张莉</option>
				</select>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-3 control-label">紧急程度：</label>
			<div class="col-sm-9">
				<div class="col-sm-9">
					<label class="radio-box">

						<input id="Radio1" class="form-control" value="0" type="radio" name="urgency">
						普通</label>
					<label class="radio-box">

						<input id="Radio2" class="form-control" value="1" type="radio" name="urgency">
						一般</label>
					<label class="radio-box">

						<input id="Radio3" class="form-control" value="2" type="radio" name="urgency">
						非常紧急</label>
				</div>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-3 control-label">任务内容：</label>
			<div class="col-sm-9">
				<input type="text" name="content" class="form-control" placeholder="请输入文本">
			</div>
		</div>
	</form>  
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: ztree-js" />
<script type="text/javascript">

	/*$(function () {
		$("#ename").change(function () {

		})
	})*/

	$(function() {
		var url = ctx + "system/menu/roleMenuTreeData";
		var options = {
			id: "menuTrees",
			url: url,
			check: { enable: true },
			expandLevel: 0
		};
		$.tree.init(options);
	});
	$("#form-role-add").validate({
		rules:{
			onkeyup: false,
			roleName:{
				remote: {
					url: ctx + "system/role/checkRoleNameUnique",
					type: "post",
					dataType: "json",
					data: {
						"roleName" : function() {
							return $.common.trim($("#roleName").val());
						}
					},
					dataFilter: function(data, type) {
						return $.validate.unique(data);
					}
				}
			},
			roleKey:{
				remote: {
					url: ctx + "system/role/checkRoleKeyUnique",
					type: "post",
					dataType: "json",
					data: {
						"roleKey" : function() {
							return $.common.trim($("#roleKey").val());
						}
					},
					dataFilter: function(data, type) {
						return $.validate.unique(data);
					}
				}
			},
			roleSort:{
				digits:true
			},
		},
		messages: {
			"roleName": {
				remote: "角色名称已经存在"
			},
			"roleKey": {
				remote: "角色权限已经存在"
			}
		},
		focusCleanup: true
	});

	function submitHandler() {
		if ($.validate.form()) {
			add();
		}
	}

	function add() {
		var title = $("input[name='title']").val();
		var user_name = $("#user_name").val();
		var endDate = $("input[name='endDate']").val();
		var startDate = $("input[name='startDate']").val();
		var urgency = $("input[name='urgency']").val();
		var content = $("input[name='content']").val();
		$.ajax({
			cache : true,
			type : "POST",
			url : ctx + "cms/task/addSave",
			data : {
				"title": title,
				"user_name": user_name,
				"endDate": endDate,
				"startDate": startDate,
				"urgency": urgency,
				"content": content
			},
			async : false,
			error : function(request) {
				$.modal.alertError("12456");
			},
			success : function(data) {
				$.operate.successCallback(data);
			}
		});
	}
</script>
</body>
</html>



